package com.jh.user.repository;


import com.jh.user.pojo.freeQuick.PassagewayBankInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface PassagewayBankinfoRepository extends JpaRepository<PassagewayBankInfo, String>,JpaSpecificationExecutor<PassagewayBankInfo> {

    @Query("select info from PassagewayBankInfo info where info.bankCardNo=:bankCardNo and info.channelProductCode=:channelProductCode")
    PassagewayBankInfo findPassagewayBankInfoByBankCardNo(@Param("bankCardNo") String bankCardNo,@Param("channelProductCode")String channelProductCode);

//    @Query("select p from PassagewayBankInfo p where p.merchantNo = :channelMerchantNo and p.channelProductCode = :channelId and p.bindStatus = '1'")
    @Query("select p from PassagewayBankInfo p where p.merchantNo = :channelMerchantNo and p.channelProductCode = :channelId")
    List<PassagewayBankInfo> findByMerchantNoAndChannelProductCode(@Param("channelMerchantNo") String channelMerchantNo, @Param("channelId") String channelId);

    @Query("select p from PassagewayBankInfo p where p.bankCardNo = :beforeCardNo and p.bindStatus = 1")
    PassagewayBankInfo findUsablePassagewayBankInfoByBankCardNo(@Param("beforeCardNo") String beforeCardNo);


}
